/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package warehouse;

import java.awt.Color;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Adriana
 */
public class Chart3DPie {

    JFreeChart chart;
    DefaultPieDataset pieDataset;

    public Chart3DPie() {
        this.chart = null;
        this.pieDataset = new DefaultPieDataset();
    }

    public void createPieDataSet(String[] name, double[] value) throws IOException {
        for (int i = 0; name[i] != null; i++) {
            pieDataset.setValue(name[i], value[i]);
        }
    }

    public void create3DPieChart(String title) {

        this.chart = ChartFactory.createPieChart3D(
                title, this.pieDataset, true, true, true);

        PiePlot3D p = (PiePlot3D) this.chart.getPlot();
        p.setForegroundAlpha(0.9f);
        p.setBackgroundAlpha(0.2f);

        this.chart.setBackgroundPaint(Color.white);
        this.chart.setAntiAlias(true);
        this.chart.setBorderVisible(false);
        this.chart.setTextAntiAlias(true);
    }

    public JFreeChart getChart() {
        return this.chart;

    }
}
